<#assign import_block>
import { Environment } from '@/environments/environment';
</#assign>

<#ibizinclude>
../@MACRO/LAYOUTPANEL_VIEW.template.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/VIEW_HEADER-BASE.vue.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/VIEW_CONTENT-BASE.vue.ftl
</#ibizinclude>

    /**
     * 登录数据对象
     *
     * @type {*}
     * @memberof LoginView
     */
    public formData: any = {
        loginname: '',
        password: ''
    }

    /**
     * 登陆处理
     *
     * @memberof Login
     */
    public handleSubmit(): void {
        if (Object.is(this.formData.loginname, '') || Object.is(this.formData.password, '')) {
            return;
        }
        const post: Promise<any> = this.$http.post(Environment.RemoteLogin, this.formData, true);
        post.then((response: any) => {
            if (response && response.status === 200) {
                const data = response.data;
                window.localStorage.setItem('token', data.token);
                window.localStorage.setItem('user', JSON.stringify(data.user));
                const url: any = this.$route.query.redirect ? this.$route.query.redirect : '*';
                this.$router.push({ path: url });
            }
        }).catch((error: any) => {
            this.$Notice.error({ title: '错误', desc: '登陆失败' });
        });

    }

<#ibizinclude>
../@MACRO/VIEW_BOTTOM-BASE.vue.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/VIEW-BASE.style.ftl
</#ibizinclude>